﻿<sdk:Page
            
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
  xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
  xmlns:ViewModels="clr-namespace:AR.ViewModels"
  xmlns:Converters="clr-namespace:AR.Converters"
  xmlns:local="clr-namespace:AR.Controls"
  xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:Entities="clr-namespace:AR.Entities" xmlns:Services="clr-namespace:AR.Web.Services"
  x:Class="AR.ListeCandidats"
  xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
 xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
 xmlns:behaviors="clr-namespace:Behavior"
xmlns:delay="clr-namespace:Delay"
  mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" >

    <sdk:Page.Resources>
        <Converters:IdStatutToColorConverter x:Key="idStatutToColorConverter"/>
    </sdk:Page.Resources>
    <sdk:Page.Style>
        <StaticResource ResourceKey="PageStyle"/>
    </sdk:Page.Style>

    <Grid x:Name="LayoutRoot" >

        <Grid.RowDefinitions>
            <RowDefinition Height="4*"/>
            <RowDefinition Height="3*"/>
        </Grid.RowDefinitions>
        <Grid x:Name="Grid_UP" Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="5*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid x:Name="ControlsGrid" Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition Width="2*"/>
                </Grid.ColumnDefinitions>

                <toolkit:Accordion Grid.Row="0" Grid.Column="5" Grid.ColumnSpan="2" VerticalAlignment="Top" SelectionMode="ZeroOrOne" SelectionSequence="CollapseBeforeExpand">
                    <toolkit:AccordionItem Header="Fonctionalités" BorderBrush="{StaticResource AtosBlue}" FontWeight="ExtraBold" Background="{StaticResource AtosBlue}" Foreground="White">
                        <Grid MinHeight="50">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <HyperlinkButton Grid.Row="0" Foreground="White" Visibility="{Binding CanaddCandidat, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TargetName="ContentFrame" NavigateUri="/CreationCandidat" Content="Ajouter Candidat"/>
                            <HyperlinkButton Grid.Row="1" Foreground="White" Visibility="{Binding CanaddCandidat, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Command="{Binding ParcourirCommmand}" Content="Importer des Candidats" />
                            <HyperlinkButton Grid.Row="2" Foreground="White" Visibility="{Binding CanshowEntretien, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  Content="Gestion des Tests" TargetName="ContentFrame" NavigateUri="/Parametrage"/>

                        </Grid>
                    </toolkit:AccordionItem>

                </toolkit:Accordion>


                <TextBlock Text="Liste des candidats" x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Foreground="{StaticResource AtosBlue}" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" />
                <toolkit:Separator Grid.Row="1" Grid.ColumnSpan="6" VerticalAlignment="Top" Margin="15,0" Foreground="{StaticResource AtosBlue}" Background="{StaticResource AtosBlue}"/>
                <sdk:Label Margin="16,0,0,0" Content="Nom" Grid.Row="1" Grid.Column="1" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <sdk:Label Margin="16,0,0,0"  Content="Prénom" Grid.Row="2" Grid.Column="1" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <sdk:Label Margin="16,0,0,0" Content="Practice" Grid.Row="4" Grid.Column="4" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <sdk:Label Margin="16,0,0,0" Content="Email" Grid.Row="4" Grid.Column="1" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <sdk:Label Content="Niveau études" Grid.Row="2" Grid.Column="4" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <sdk:Label Content="Niveau expérience" Grid.Row="3" Grid.Column="4" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <sdk:Label Content="Dernier employeur" Grid.Row="3" Grid.Column="1" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <sdk:Label Margin="16,0,0,0" Content="Téléphone" Grid.Row="1" Grid.Column="4" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>

                <TextBox Text="{Binding Criteria.Nom, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="2"  Height="25"/>
                <TextBox Text="{Binding Criteria.Prenom, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="2" Height="25" />
                <TextBox Text="{Binding Criteria.Email, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="2" Height="25" />
                <TextBox Text="{Binding Criteria.DernierEmployeur, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Grid.Column="2" Height="25" />
                <TextBox Text="{Binding Criteria.Tel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="5"  Height="25"/>
                <toolkit:Separator Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="5" VerticalAlignment="Top" Foreground="{StaticResource AtosBlue}"  Background="{StaticResource AtosBlue}" />
                <toolkit:Separator Grid.Column="1" Grid.Row="8" Grid.ColumnSpan="5" VerticalAlignment="Top" Foreground="{StaticResource AtosBlue}"  Background="{StaticResource AtosBlue}" />
                <sdk:Label Margin="16,0,0,0" Content="Tags" Grid.Row="5" Grid.Column="1" FontStyle="Italic" FontWeight="ExtraBold" Foreground="{StaticResource AtosBlue}"/>
                <TextBox Text="{Binding SearchTagsTxt, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="2" Height="25" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding RechercheTagsCommand, Mode=OneWay}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
                <toolkit:ListBoxDragDropTarget Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="2" AllowDrop="true" 
                                               HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Drop">
                            <i:InvokeCommandAction Command="{Binding ajoutTagCommand, Mode=OneWay}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <ListBox ItemsSource="{Binding TagsTrouves,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" 
                             ItemTemplate="{StaticResource PhotographTemplate}" Background="AliceBlue"                            
                             >
                        <!-- Style="{StaticResource WrapListBox}" -->
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel Orientation="Horizontal" CanHorizontallyScroll="False" CanVerticallyScroll="True"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </toolkit:ListBoxDragDropTarget>

                <StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="3" Grid.RowSpan="2" HorizontalAlignment="Center">
                    <Image Source="../../Assets/icons/Navigate_right_Icon_16.png" Width="16" Height="16" />
                    <Image Source="../../Assets/icons/Navigate_right_Icon_16.png" Width="16" Height="16" />
                    <Image Source="../../Assets/icons/Navigate_right_Icon_16.png" Width="16" Height="16" />
                    <Image Source="../../Assets/icons/Navigate_right_Icon_16.png" Width="16" Height="16" />
                </StackPanel>

                <toolkit:ListBoxDragDropTarget  Grid.Row="6" Grid.Column="4" Grid.ColumnSpan="2" Grid.RowSpan="2"  AllowDrop="true" 
                                                HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Drop">
                            <i:InvokeCommandAction Command="{Binding supressionTagCommand, Mode=OneWay}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <ListBox ItemsSource="{Binding SelectedTags,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                             ItemTemplate="{StaticResource PhotographTemplate}"                             
                             Background="GreenYellow"
                             >
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel Orientation="Horizontal" CanHorizontallyScroll="False" CanVerticallyScroll="True"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </toolkit:ListBoxDragDropTarget>
                <!--<ListBox Grid.ColumnSpan="2" Grid.Column="4"  Grid.Row="5"
                         ScrollViewer.HorizontalScrollBarVisibility="Visible" SelectionMode="Extended"
                        ItemsSource="{Binding Tags,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" DisplayMemberPath="NOM">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel Orientation="Horizontal" CanHorizontallyScroll="False" CanVerticallyScroll="True"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <i:Interaction.Behaviors>
                        <behaviors:MultiSelectionBehavior SelectedItems="{Binding SelectedTags}" />
                    </i:Interaction.Behaviors>
                </ListBox>-->
                <ComboBox Height="20" ItemsSource="{Binding NiveauxEtudes}"  SelectedIndex="0" DisplayMemberPath="INTITULE" SelectedValuePath="ID_ETUDE"  Grid.Row="2" Grid.Column="5" SelectedValue="{Binding Criteria.ID_ETUDES, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <ComboBox Height="20" ItemsSource="{Binding NiveauxExperience}"  SelectedIndex="0" DisplayMemberPath="INTITULE" SelectedValuePath="ID_EXPERIENCE" Grid.Row="3" Grid.Column="5" SelectedValue="{Binding Criteria.ID_EXPERIENCE, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                <ComboBox Height="20" ItemsSource="{Binding Practices}" SelectedIndex="0" DisplayMemberPath="PRACTICE1" SelectedValuePath="ID_PRACTICE" Grid.Row="4" Grid.Column="5" SelectedValue="{Binding Criteria.ID_PRACTICE, Mode=TwoWay}" />
                <StackPanel  Grid.Row="8"  Grid.Column="3" Grid.ColumnSpan="3" Orientation="Horizontal" HorizontalAlignment="Right" Height="40">
                    <Button Command="{Binding SearchCandidatCommand2}" HorizontalAlignment="Left" Width="100" >
                        <Button.Content>
                            <StackPanel Orientation="Horizontal">
                                <Image Source="../../Assets/icons/Search_Male_User_Icon_16.png" Width="16" Height="16" />
                                <TextBlock Text="Rechercher" />
                            </StackPanel>
                        </Button.Content>
                    </Button>
                    <Border MinWidth="10" />
                            
                    <Button Command="{Binding InitialiserCommand}" HorizontalAlignment="Right" Width="100" >
                        <Button.Content>
                            <StackPanel Orientation="Horizontal">
                                <Image Source="../../Assets/icons/Eraser_Icon_16.png" Width="16" Height="16" />
                                <TextBlock Text="Vider tout"/>
                            </StackPanel>
                        </Button.Content>
                    </Button>

                </StackPanel>
                <toolkit:Separator Grid.Row="6" Grid.RowSpan="6" VerticalAlignment="Bottom"  Grid.ColumnSpan="6" Margin="15,0" Foreground="{StaticResource AtosBlue}" Background="{StaticResource AtosBlue}"/>
                
            </Grid>

        </Grid>
        <Grid x:Name="ListGrid" Grid.Row="1">
            <Border Margin="0,10,0,0" Background="{StaticResource AtosBlue}" CornerRadius="3" >

                <sdk:DataGrid   x:Name="CandidatGrid" Width="Auto"  Height="Auto" ItemsSource="{Binding CustomCandidatsResult}"
           	MouseRightButtonDown="_grid_MouseRightButtonDown" AutoGenerateColumns ="False" IsReadOnly="True" Margin="15,15,15,15" ScrollViewer.VerticalScrollBarVisibility="Auto"  SelectedItem="{Binding SelectedItem, Mode=TwoWay}">

                    <i:Interaction.Behaviors>
                        <behaviors:DataGridDoubleClickBehavior
                			DoubleClickCommand="{Binding DetailsCommand}" 
                			CommandParameter="{Binding SelectedItem, ElementName=CandidatGrid}"/>
                    </i:Interaction.Behaviors>

                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu Visibility="{Binding VisibilityContextMenu,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                            <toolkit:MenuItem Header="Copier Le Code Test" Tag="{Binding}" Command="{Binding CodeTestCommand}" 
                			                             CommandParameter="{Binding SelectedItem, ElementName=CandidatGrid}" />
                            <toolkit:MenuItem Header="Afficher L'historique du candidat" Command="{Binding HistoriqueCandidatCommand}" 
                			                            CommandParameter="{Binding SelectedItem, ElementName=CandidatGrid}" Tag="{Binding}" />
                            <toolkit:MenuItem Header="Exporter la Liste des Candidats" Command="{Binding ExportCandidatsCommand}"  />
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Header="Nom" Binding="{Binding candidat.NOM}"/>
                        <sdk:DataGridTextColumn Header="Prénom" Binding="{Binding candidat.PRENOM}" />
                        <sdk:DataGridTemplateColumn Header="Date de naissance" Width="SizeToHeader">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding candidat.DATENAISSANCE, StringFormat='{}{0:dd/MM/yyyy}'}"/>

                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTextColumn Header="Téléphone" Binding="{Binding candidat.TEL}" />
                        <sdk:DataGridTextColumn Header="Niveau études " Binding="{Binding candidat.NIVEAU_ETUDE.INTITULE}" />
                        <sdk:DataGridTextColumn Header="Niveau expérience " Binding="{Binding candidat.NIVEAU_EXPERIENCE.INTITULE}" />
                        <sdk:DataGridTextColumn Header="Dernier employeur " Binding="{Binding candidat.DERNIER_EMPLOYEUR}" />
                        <sdk:DataGridTextColumn Header="Practice" Binding="{Binding candidat.PRACTICE.PRACTICE1}" />
                        <sdk:DataGridTextColumn Header="Code Test" Binding="{Binding candidat.CODE_TEST }"  />
                        <sdk:DataGridTextColumn Header="Etat" Binding="{Binding candidat.STATUT_CANDIDAT.INTITULE}" >
                            <sdk:DataGridTextColumn.ElementStyle>
                                <Style TargetType="TextBlock" >
                                    <Setter Property="Foreground" Value="{Binding Path=candidat.ID_STATUT, Converter={StaticResource idStatutToColorConverter}}"/>
                                </Style>
                                <!--SolidColorBrush Color="{Binding Path=candidat.ID_STATUT, Converter={StaticResource idStatutToColorConverter}}" /-->
                            </sdk:DataGridTextColumn.ElementStyle>
                        </sdk:DataGridTextColumn>
                        <sdk:DataGridTemplateColumn Header="Entretien Orale" Width="SizeToHeader">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <HyperlinkButton IsEnabled="{Binding entretienOraleEnabled}" Content="{Binding entretienOraleContent}" Tag="{Binding Id}" 
                                 NavigateUri="{Binding entretienOraleUri}" 
                                 TargetName="ContentFrame" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Entretien écrit" Width="SizeToHeader">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <HyperlinkButton IsEnabled="{Binding entretienEcritEnabled}" Content="{Binding entretienEcritContent}" Tag="{Binding Id}" 
                                 NavigateUri="{Binding entretienEcritUri}" 
                                 TargetName="ContentFrame" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>                    
                        <sdk:DataGridTextColumn Header="" Binding="{Binding STATUT_CANDIDAT.INTITULE}" />
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>

            </Border>
        </Grid>

    </Grid>

</sdk:Page>